package com.zqweb.gulimall.product.web;

import com.zqweb.gulimall.product.service.SkuInfoService;
import com.zqweb.gulimall.product.vo.SkuInfoItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    @RequestMapping("/{skuId}.html")
    public String toItemWithSkuId(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("进入skuIdHtml方法...");
        // 带上skuId，查出该skuId关联的所有详情信息数据，传递给item.html页面
        SkuInfoItemVo itemVo = skuInfoService.getItemDetailsBySkuId(skuId);
        model.addAttribute("item",itemVo);
        return "item";
    }

}
